<?php

namespace app\circle\model;


class AdminModel extends BaseModel
{
    protected $name = 'circle_admin'; //定义用户表
    //开启自动写入时间戳
    protected $autoWriteTimestamp = false;
    // 定义自动完成的属性
    protected $auto = []; //新增修改
    protected $insert = []; //插入
    protected $update = []; //修改

    protected function setAdminPassAttr($value)
    {
        return md5($value);
    }
    /**
     * 用户登录
     * @param $adminName
     * @param $adminPass
     * @return array|bool|false|\PDOStatement|string|\think\Model
     */
    public function checkLogin($adminName,$adminPass){
        $info = $this->where('admin_name',$adminName)->find();
        if(empty($info)){
            $this->error = '用户不存在！';
            return false;
        }
        if($info['admin_pass']==md5($adminPass)){
            $info = $info->toArray();
            unset($info['admin_pass']);
            return $info;
        }else{
            $this->error = '密码输入错误！';
            return false;
        }
    }
}